package com.jack.leetcode.eachproblem_2020;

import java.util.Arrays;

public class 三角形的最大周长 {

    public int largestPerimeter(int[] A) {
        int n = A.length;
        Arrays.sort(A);
        int result = 0;
        for(int i = n - 3;i >= 0;i--){
            if(A[i] + A[i + 1] > A[i + 2]){
                result = Math.max(result, A[i] + A[i + 1] + A[i + 2]);
                break;
            }
        }
        return result;
    }
}
